From: Bartosz DziewoƄski Date: Mon, 29 Feb 2016 22:05:32 +0000 (+0100) Subject: CategoryViewer: Do opportunistic category recounts for mismatched file counts, too X-Git-Tag: 1.31.0-rc.0~7787^2 X-Git-Url: http://git.cyclocoop.org/%22.%24info%5B?a=commitdiff_plain;h=ce5a36ab59c235753541f31c3c970bbe12222896;p=lhc%2Fweb%2Fwiklou.git CategoryViewer: Do opportunistic category recounts for mismatched file counts, too There are some categories on Commons that have no files, but are recorded to have some, e.g. [1] appears to have 15 files [2]. We have logic to fix these, but it wasn't being checked for file counts (only pages and subcats). [1] https://commons.wikimedia.org/wiki/Category:Police_of_Mexico,_D._F._vehicles [2] https://commons.wikimedia.org/w/index.php?title=Category:Police_of_Mexico,_D._F._vehicles&action=info Change-Id: If88fc15347eb592e957452884c2179d7c237bd2c --- diff --git a/includes/CategoryViewer.php b/includes/CategoryViewer.php index b912603611..f7490033d4 100644 --- a/includes/CategoryViewer.php +++ b/includes/CategoryViewer.php @@ -387,6 +387,7 @@ class CategoryViewer extends ContextSource { $r = ''; $rescnt = count( $this->children ); $dbcnt = $this->cat->getSubcatCount(); + // This function should be called even if the result isn't used, it has side-effects $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'subcat' ); if ( $rescnt > 0 ) { @@ -417,6 +418,7 @@ class CategoryViewer extends ContextSource { $dbcnt = $this->cat->getPageCount() - $this->cat->getSubcatCount() - $this->cat->getFileCount(); $rescnt = count( $this->articles ); + // This function should be called even if the result isn't used, it has side-effects $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'article' ); if ( $rescnt > 0 ) { @@ -437,10 +439,11 @@ class CategoryViewer extends ContextSource { function getImageSection() { $r = ''; $rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery ); - if ( $rescnt > 0 ) { - $dbcnt = $this->cat->getFileCount(); - $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'file' ); + $dbcnt = $this->cat->getFileCount(); + // This function should be called even if the result isn't used, it has side-effects + $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'file' ); + if ( $rescnt > 0 ) { $r .= "
\n"; $r .= '

' . $this->msg(